package org.ufinity.hsms.module.setting;
import org.ufinity.hsms.R;
import org.ufinity.hsms.common.activity.BaseActivity;
import org.ufinity.hsms.common.application.HSMApplication;
import org.ufinity.hsms.common.utils.SystemUtils;
import org.ufinity.hsms.module.TabGroupActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class SettingActivity extends BaseActivity implements OnClickListener{
	
	
	public static final String TAG = "SettingActivity";
	private HSMApplication application;
	
	TextView txt_1;
	TextView txt_2;
	TextView txt_3;
	TextView txt_4;
	TextView txt_5;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		instance = this;
		application = getBaseApplication();
		application.addActivity(instance);
		setContentView(R.layout.setting);
		initView();
	}

	private void initView() {
		txt_1 = (TextView) findViewById(R.id.txt_1);
		txt_1.setOnClickListener(this);
		txt_2 = (TextView) findViewById(R.id.txt_2);
		txt_2.setOnClickListener(this);
		txt_3 = (TextView) findViewById(R.id.txt_3);
		txt_3.setOnClickListener(this);
		txt_4 = (TextView) findViewById(R.id.txt_4);
		txt_4.setOnClickListener(this);
		txt_5 = (TextView) findViewById(R.id.txt_5);
		txt_5.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		int id = v.getId();
		if(id == txt_1.getId()){
			((TabGroupActivity) getParent()).startChildActivity("ServiceSettingActivity", new Intent(getParent(),
					ServiceSettingActivity.class));
		}else if(id == txt_2.getId()){
			((TabGroupActivity) getParent()).startChildActivity("AlarmSettingActivity", new Intent(getParent(),
					AlarmSettingActivity.class));
		}else if(id == txt_3.getId()){
			((TabGroupActivity) getParent()).startChildActivity("LanguageSettingActivity", new Intent(getParent(),
					LanguageSettingActivity.class));
		}else if(id == txt_4.getId()){
			((TabGroupActivity) getParent()).startChildActivity("RefreshAndConfigSettingActivity", new Intent(getParent(),
					RefreshAndConfigSettingActivity.class));
		}else if(id == txt_5.getId()){
			((TabGroupActivity) getParent()).startChildActivity("ContantSettingActivity", new Intent(getParent(),
					ContantSettingActivity.class));
		}
	}

	@Override
	public boolean dispatchKeyEvent(KeyEvent event) {
		// TODO Auto-generated method stub
		return super.dispatchKeyEvent(event);
	}

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		super.onBackPressed();
	}
	 
	/* (non-Javadoc)
	 * 锁back键 控制提示退出
	 * @see org.ufinity.hsms.common.activity.BaseActivity#onKeyDown(int, android.view.KeyEvent)
	 */
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
			SystemUtils.openOptionsDialog(getParent(), application);
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	
}
